package coding.datastructures;

public class UniqueCharacter {

	public static void main(String[] args) {
		// myMethod();
		
		isUniqueChars2("this is");
	}

	public static boolean isUniqueChars2(String str) {
		
		if (str.length() > 256)
			return false;
		boolean[] char_set = new boolean[256];
		for (int i = 0; i < str.length(); i++) {
 			int val = str.charAt(i);
			
			if (char_set[val]) {
				System.out.println("already found the duplicated character");
				return false;
			}
			char_set[val] = true;
		}
		return true;
	}

	public static void myMethod() {
		String word = "abcdeefg";
		StringBuffer strBuffer = new StringBuffer();
		for (String c : word.split("")) {
			String subString = strBuffer.substring(0);

			if (subString.contains(c) && !c.isEmpty()) {
				System.out.println("This word is not uique character");
				System.out.println("duplicated character: " + c);
				return;
			}
			System.out.println("buffer: " + strBuffer.append(c));
		}
	}

}
